/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lifxue.jqda.ui.util;

import java.util.Iterator;
import java.util.Map;
import javax.swing.SwingUtilities;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.lifxue.jqda.util.GlobalConstant;
import org.lifxue.jqda.util.GlobalVar;
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.skin.SkinInfo;

/**
 *
 * @author lifxue
 */
public class UIUtil {

    private static Log logger = LogFactory.getLog(UIUtil.class);

    public static void setUI() {

        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {

                String lookandfeel = GlobalVar.CONFIG.get(GlobalConstant.CONFIG_LOOK_AND_FEEL);
                if (lookandfeel == null || lookandfeel.trim().equals("")) {
                    //UIManager.setLookAndFeel(GlobalConstant.DEFAULT_LOOK_AND_FEEL);
                    SubstanceLookAndFeel.setSkin(GlobalConstant.DEFAULT_LOOK_AND_FEEL);
                } else {
                    Map<String, SkinInfo> hm = SubstanceLookAndFeel.getAllSkins();
                    Iterator skins = hm.entrySet().iterator();
                    while (skins.hasNext()) {
                        java.util.Map.Entry entry = (java.util.Map.Entry) skins.next();
                        SkinInfo skinInfo = (SkinInfo) entry.getValue();
                        if (lookandfeel.equals(skinInfo.getClassName())) {
                            SubstanceLookAndFeel.setSkin(lookandfeel);
                            break;
                        }
                    }
                }

            }
        });
    }
}
